import uuid

import pytest

from recruit.domain.models.resume_salary import (
    BaseResumeSalary,
    ResumeSalaryCreate,
    ResumeSalaryResult,
    ResumeSalaryUpdate,
)
from .utils import check_attr_model, check_json_schema


@pytest.mark.parametrize(
    'data, keys', [
        (
                {
                    'salary': '500000 руб.'
                },
                ('salary',)
        )
    ]
)
def test_resume_salary_base(data: dict[str, str], keys: tuple[str]) -> None:
    check_attr_model(BaseResumeSalary, data)
    check_json_schema(BaseResumeSalary, keys)


@pytest.mark.parametrize(
    'data', [
        {'salary': ''},
        {'salary': '500000руб'},
        {'salary': '500000 руб .'}
    ]
)
def test_validate_in_resume_salary_base(data: dict[str, str]) -> None:
    with pytest.raises(ValueError):
        BaseResumeSalary(**data)


@pytest.mark.parametrize(
    'data, keys', [
        (
                {
                    'salary': '500000 руб.'
                },
                ('salary',)
        )
    ]
)
def test_resume_salary_create(data: dict[str, str], keys: tuple[str]) -> None:
    check_attr_model(ResumeSalaryCreate, data)
    check_json_schema(ResumeSalaryCreate, keys)


@pytest.mark.parametrize(
    'data', [
        {'salary': ''},
        {'salary': '500000руб'},
        {'salary': '500000 руб .'}
    ]
)
def test_validate_in_resume_salary_create(data: dict[str, str]) -> None:
    with pytest.raises(ValueError):
        ResumeSalaryCreate(**data)


@pytest.mark.parametrize(
    'data, keys', [
        (
                {
                    'id': uuid.uuid4(),
                    'salary': '500000 руб.'
                },
                ('id', 'salary')
        )
    ]
)
def test_resume_salary_result(data: dict[str, str], keys: tuple[str]) -> None:
    check_attr_model(ResumeSalaryResult, data)
    check_json_schema(ResumeSalaryResult, keys)


@pytest.mark.parametrize(
    'data, keys', [
        (
                {
                    'salary': '500000 руб.'
                },
                ('salary',)
        )
    ]
)
def test_resume_salary_update(data: dict[str, str], keys: tuple[str]) -> None:
    check_attr_model(ResumeSalaryUpdate, data)
    check_json_schema(ResumeSalaryUpdate, keys)
    check_attr_model(ResumeSalaryUpdate, {}, tuple(data))
    check_json_schema(ResumeSalaryUpdate, keys)
